﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="GestionUsuarios.aspx.cs" Inherits="API_CIC.UsuariosRoles.GestionUsuarios" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            width: 99px;
        }
        .style3
        {
            width: 308px;
            height: 33px;
        }
        .style4
        {
            width: 424px;
            height: 33px;
        }
        .style5
        {
            width: 424px;
            height: 44px;
        }
        .style6
        {
            width: 424px;
            height: 40px;
        }
        .style8
        {
            width: 308px;
            height: 40px;
        }
        .style9
        {
            width: 424px;
            height: 41px;
        }
        .style10
        {
            width: 308px;
            height: 41px;
        }
        .style11
        {
            width: 424px;
            height: 39px;
        }
        .style12
        {
            width: 308px;
            height: 39px;
        }
        .style14
        {
            height: 57px;
        }
        .style15
        {
            width: 424px;
            height: 57px;
        }
        </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <center><h1>Gestión de Usuarios</h1></center>
<br>
    <table style="width:100%;">
        <tr>
            <td align="left" class="leftColumn" valign="top">
    <asp:Menu ID="MenuGestionUsuarios" runat="server" BackColor="#B5C7DE" 
                    DynamicHorizontalOffset="2" Font-Names="Verdana" 
        Font-Size="0.8em" ForeColor="#284E98" onmenuitemclick="Menu1_MenuItemClick" 
        StaticSubMenuIndent="10px">
        <DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
        <DynamicMenuStyle BackColor="#B5C7DE" />
        <DynamicSelectedStyle BackColor="#507CD1" />
        <Items>
            <asp:MenuItem Text="Consultar Usuario" Value="1" Selected="True"></asp:MenuItem>
            <asp:MenuItem Text="Agregar Usuario" Value="0"></asp:MenuItem>
        </Items>
        <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
        <StaticSelectedStyle BackColor="#507CD1" />
    </asp:Menu>
            </td>
            <td>
               <asp:Panel ID="Panel1" runat="server" BorderColor="#000066" BorderStyle="Solid" 
        BorderWidth="2px">
        <asp:MultiView ID="MultiView1" runat="server" 
    onactiveviewchanged="MultiView1_ActiveViewChanged" ActiveViewIndex="1">
            <asp:View ID="ViewAgregar" runat="server">
                <center>
                    <h3>
                        Agregar Usuarios</h3>
                    <p>
                        &nbsp;</p>
                </center>
                <table style="width:100%;" border="Blue">
                    <tr>
                        <td align="right" class="style5" valign="middle" height="40">
                            <asp:RangeValidator ID="RangeValidator1" runat="server" 
                                ControlToValidate="txtCedula" ErrorMessage="Sólo números (9 dígitos)" 
                                ForeColor="Red" MaximumValue="999999999" MinimumValue="100000000" 
                                Type="Integer" ValidationGroup="1"></asp:RangeValidator>
                            &nbsp;&nbsp; Cédula (#########):
                            <asp:TextBox ID="txtCedula" runat="server" Height="22px" 
                                style="margin-left: 0px" Width="188px"></asp:TextBox>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" 
                                ControlToValidate="txtCedula" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style6">
                            Nombre:<asp:TextBox ID="txtNombre" runat="server" style="margin-left: 4px" 
                                Width="187px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                                ControlToValidate="txtNombre" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style6">
                            Apellido1:
                            <asp:TextBox ID="txtApellido1" runat="server" style="margin-left: 0px" 
                                Width="187px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                                ControlToValidate="txtApellido1" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                        <td class="style8" valign="middle">
                            Apellido2:<asp:TextBox ID="txtApellido2" runat="server" 
                                style="margin-left: 0px" Width="187px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style9">
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                ControlToValidate="txtEmail" ErrorMessage="Email Inválido" ForeColor="Red" 
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                                ValidationGroup="1"></asp:RegularExpressionValidator>
                            Email:
                            <asp:TextBox ID="txtEmail" runat="server" style="margin-left: 0px" 
                                Width="187px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                ControlToValidate="txtEmail" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                        <td class="style10" valign="middle">
                            Teléfono:
                            <asp:TextBox ID="txtTelefono" runat="server" style="margin-left: 0px" 
                                Width="187px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style6">
                            Usuario:&nbsp;<asp:TextBox ID="txtUsuario" runat="server" Width="185px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                ControlToValidate="txtUsuario" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style11">
                            Contraseña:
                            <asp:TextBox ID="txtContrasena" runat="server" TextMode="Password" 
                                Width="185px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                ControlToValidate="txtContrasena" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                        <td class="style12">
                            Confirmar Contraseña:
                            <asp:TextBox ID="txtContrasenaConfirma" runat="server" TextMode="Password" 
                                Width="161px"></asp:TextBox>
                            <asp:CompareValidator ID="CompareValidator1" runat="server" 
                                ControlToCompare="txtContrasena" ControlToValidate="txtContrasenaConfirma" 
                                ErrorMessage="Contraseñas diferentes" ForeColor="Red" ValidationGroup="1"></asp:CompareValidator>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ControlToValidate="txtContrasenaConfirma" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="1">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style15">
                            Escuela:
                            <asp:DropDownList ID="ddlEscuela" runat="server" DataSourceID="LinqDataSource1" 
                                DataTextField="NOM_ESCUELA" DataValueField="ID_ESCUELA" Height="35px" 
                                style="margin-left: 0px" Width="182px">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                ControlToValidate="ddlEscuela" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>
                            <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                                ContextTypeName="API_CIC.LinqClasesDataContext" EntityTypeName="" 
                                OrderBy="NOM_ESCUELA" TableName="SGAPFESCUELAs">
                            </asp:LinqDataSource>
                        </td>
                        <td class="style14">
                        Rol Administrativo:
                            <asp:DropDownList ID="ddlRolAdmi" runat="server" 
                                DataSourceID="LinqDataSource3" DataTextField="NOM_ROL" 
                                DataValueField="ID_ROL" Height="16px" Width="148px">
                            </asp:DropDownList>

                            <asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server" 
                                ControlToValidate="ddlRolAdmi" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="1">*</asp:RequiredFieldValidator>

                            <asp:LinqDataSource ID="LinqDataSource3" runat="server" 
                                ContextTypeName="API_CIC.LinqClasesDataContext" EntityTypeName="" 
                                TableName="SGAPFROLEs">
                            </asp:LinqDataSource>

                        </td>
                    </tr>
                </table>
                <center>
                    <br />
                    <asp:Button ID="btnAgregar" runat="server" onclick="btnAgregar_Click" 
                        Text="Agregar" ValidationGroup="1" />
                </center>
                <br />
            </asp:View>
            <asp:View ID="ViewConsultar" runat="server">
                <center>
                    <h3>
                        Consultar Usuarios</h3>
                    <p>
                        <asp:GridView ID="gvUsuarios" runat="server" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                            DataKeyNames="ID_CEDULA" DataSourceID="LinqDataSource2" ForeColor="#333333" 
                            GridLines="None" onrowdeleting="gvUsuarios_RowDeleting" 
                            onload="gvUsuarios_Load">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:CommandField SelectText="Seleccionar" ShowSelectButton="True" 
                                    ButtonType="Image" SelectImageUrl="~/images/arrow_right_pagging.gif" />
                                <asp:BoundField DataField="ID_CEDULA" HeaderText="Cédula" ReadOnly="True" 
                                    SortExpression="ID_CEDULA" />
                                <asp:BoundField DataField="TXT_USUARIO" HeaderText="Usuario" 
                                    SortExpression="TXT_USUARIO" />
                                <asp:BoundField DataField="NOM_USUARIOS" HeaderText="Nombre" 
                                    SortExpression="NOM_USUARIOS" />
                                <asp:BoundField DataField="NOM_APELLIDO1" HeaderText="Apellido1" 
                                    SortExpression="NOM_APELLIDO1" />
                                <asp:BoundField DataField="NOM_APELLIDO2" HeaderText="Apellido2" 
                                    SortExpression="NOM_APELLIDO2" />
                                <asp:BoundField DataField="TXT_EMAIL" HeaderText="Email" 
                                    SortExpression="TXT_EMAIL" />
                                <asp:BoundField DataField="TXT_TELEFONO" HeaderText="Teléfono" 
                                    SortExpression="TXT_TELEFONO" />
                                <asp:TemplateField ShowHeader="False"><ItemTemplate><asp:LinkButton ID="Elimina" runat="server" CausesValidation="False" 
                                            CommandName="Delete" 
                                            OnClientClick="return confirm(&quot;¿Desea eliminar este usuario?&quot;);" 
                                            Text="Eliminar" /></ItemTemplate><ControlStyle ForeColor="#CC0000" /></asp:TemplateField>
                            </Columns>
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                        </asp:GridView>
                        <asp:Button ID="btnModificar" runat="server" Text="Modificar" 
                            onclick="btnModificar_Click" />
                        <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                            ContextTypeName="API_CIC.LinqClasesDataContext" EnableDelete="True" 
                            EntityTypeName="" TableName="SGAPFUSUARIOs">
                        </asp:LinqDataSource>
                    </p>
                </center>
            </asp:View>
            <asp:View ID="ViewModificar" runat="server" onload="ViewModificar_Load">
                <center><h3>Modificar Usuario</h3>
                    <p>
                        &nbsp;</p>
                </center>
                <table style="width:100%;">
                    <tr>
                        <td align="right" class="style4" valign="middle">
                            <asp:RangeValidator ID="RangeValidator2" runat="server" 
                                ControlToValidate="txtCedulaModificar" ErrorMessage="Sólo números (9 dígitos)" 
                                ForeColor="Red" MaximumValue="999999999" MinimumValue="100000000" 
                                Type="Integer" ValidationGroup="2"></asp:RangeValidator>
                            Cédula(#########):
                            <asp:TextBox ID="txtCedulaModificar" runat="server" style="margin-left: 0px" 
                                Width="188px"></asp:TextBox>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator18" runat="server" 
                                ControlToValidate="txtCedulaModificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style4">
                            Nombre:<asp:TextBox ID="txtNombreModificar" runat="server" 
                                style="margin-left: 4px" Width="187px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" 
                                ControlToValidate="txtNombreModificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style4">
                            Apellido1:
                            <asp:TextBox ID="txtApellido1Modificar" runat="server" style="margin-left: 0px" 
                                Width="187px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" 
                                ControlToValidate="txtApellido1Modificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                        <td class="style3" valign="middle">
                            Apellido2:<asp:TextBox ID="txtApellido2Modificar" runat="server" 
                                style="margin-left: 0px" Width="187px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style4">
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                ControlToValidate="txtEmailModificar" ErrorMessage="Email Inválido" 
                                ForeColor="Red" 
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                                ValidationGroup="2"></asp:RegularExpressionValidator>
                            Email:
                            <asp:TextBox ID="txtEmailModificar" runat="server" style="margin-left: 0px" 
                                Width="187px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" 
                                ControlToValidate="txtEmailModificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                        <td class="style3" valign="middle">
                            Teléfono:
                            <asp:TextBox ID="txtTelefonoModificar" runat="server" style="margin-left: 0px" 
                                Width="187px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style4">
                            Usuario:&nbsp;<asp:TextBox ID="txtUsuarioModificar" runat="server" Width="185px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" 
                                ControlToValidate="txtUsuarioModificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style4">
                            Contraseña:
                            <asp:TextBox ID="txtContrasenaModificar" runat="server" TextMode="Password" 
                                Width="185px" ValidationGroup="1"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" 
                                ControlToValidate="txtContrasenaModificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                        <td class="style3">
                            Confirmar Contraseña:
                            <asp:TextBox ID="txtContrasenaConfirmaModificar" runat="server" 
                                TextMode="Password" Width="161px"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server" 
                                ControlToValidate="txtContrasenaConfirmaModificar" 
                                ErrorMessage="Campo Requerido" ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                            <asp:CompareValidator ID="CompareValidator2" runat="server" 
                                ControlToCompare="txtContrasenaModificar" 
                                ControlToValidate="txtContrasenaConfirmaModificar" 
                                ErrorMessage="Contraseñas diferentes" ForeColor="Red" ValidationGroup="2"></asp:CompareValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="style4">
                            Escuela:
                            <asp:DropDownList ID="ddlEscuelaModificar" runat="server" 
                                DataSourceID="LinqDataSource1" DataTextField="NOM_ESCUELA" 
                                DataValueField="ID_ESCUELA" Height="35px" style="margin-left: 0px" 
                                Width="182px" ValidationGroup="1">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server" 
                                ControlToValidate="ddlEscuelaModificar" ErrorMessage="Campo Requerido" 
                                ForeColor="Red" ValidationGroup="2">*</asp:RequiredFieldValidator>
                        </td>
                        <td>
                        Rol Administrativo:
                            <asp:DropDownList ID="ddlRolAdmiModificar" runat="server" 
                                DataSourceID="LinqDataSource4" DataTextField="NOM_ROL" 
                                DataValueField="ID_ROL" Height="16px" Width="148px" ValidationGroup="1">
                            </asp:DropDownList>

                            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" 
                                ControlToValidate="ddlRolAdmiModificar" ErrorMessage="Campo Requerido" ForeColor="Red" 
                                ValidationGroup="2">*</asp:RequiredFieldValidator>

                            <asp:LinqDataSource ID="LinqDataSource4" runat="server" 
                                ContextTypeName="API_CIC.LinqClasesDataContext" EntityTypeName="" 
                                TableName="SGAPFROLEs">
                            </asp:LinqDataSource>

                        </td>
                    </tr>
                </table>
                <br />
                <center>
                    <asp:Button ID="btnGuardarModificar" runat="server" Text="Guardar" 
                        onclick="btnGuardarModificar_Click" ValidationGroup="2" /></center>

            </asp:View>
        </asp:MultiView>
    </asp:Panel></td>
        
        </tr>
    </table>
    </asp:Content>
